var _mm = require('util/mm.js');
var _cart = {
    getCartCount : function(resolve,reject){
        _mm.request({
            url : _mm.getServerHost('/cart/get_cart_product_count.do'),
            success : resolve,
            error : reject
        });
    },
    addToCart : function(productInfo,resolve,reject){
        _mm.request({
            url : _mm.getServerHost('/cart/add.do'),
            data : productInfo,
            success : resolve,
            error : reject
        });
    },
    getCartList : function(resolve,reject){
        _mm.request({
            url : _mm.getServerHost('/cart/list.do'),
            success : resolve,
            error : reject
        });
    },
    selectProduct : function(productId,resolve,reject){
        _mm.request({
            url : _mm.getServerHost('/cart/select.do'),
            data : {
                productId : productId
            },
            success : resolve,
            error : reject
        });
    },
    unSelectProduct : function(productId,resolve,reject){
        _mm.request({
            url : _mm.getServerHost('/cart/un_select.do'),
            data : {
                productId : productId
            },
            success : resolve,
            error : reject
        });
    },
    selectAllProduct : function(resolve,reject){
        console.log('selectAllProduct');
        _mm.request({
            url : _mm.getServerHost('/cart/select_all.do'),
            success : resolve,
            error : reject
        });
    },
    unselectAllProduct : function(resolve,reject){
        console.log('unSelectAllProduct');
        _mm.request({
            url : _mm.getServerHost('/cart/un_select_all.do'),
            success : resolve,
            error : reject
        });
    },
    //更新购物车数量
    updateProduct : function(productInfo,resolve,reject){
        _mm.request({
            url : _mm.getServerHost('/cart/update.do'),
            data : productInfo,
            success : resolve,
            error : reject
        });
    },
    //删除商品
    deleteProduct : function(productIds,resolve,reject){
        _mm.request({
            url : _mm.getServerHost('/cart/delete_product.do'),
            data : {
                productIds : productIds
            },
            success : resolve,
            error : reject
        });
    }
};
module.exports = _cart;